import 'package:flutter/material.dart';
import 'package:heven/widget/customSwitch.dart';

class LabelWidget extends StatefulWidget {
  const LabelWidget(
      {super.key, this.name, this.showRight = false, this.onChanged});
  final String? name;
  final bool? showRight;
  final ValueChanged<bool>? onChanged;
  @override
  State<LabelWidget> createState() => _LabelWidgetState();
}

class _LabelWidgetState extends State<LabelWidget> {
  bool _show = false;

  @override
  void initState() {
    super.initState();
    _show = widget.showRight!;
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(
          flex: 1,
          child: Text(
            widget.name!,
            style: const TextStyle(
              color: Color(0xFFFFFFFF),
              fontSize: 13,
            ),
          ),
        ),
        Offstage(
          offstage: !_show,
          child: Row(
            children: [
              const Text(
                '纯音乐',
                style: TextStyle(
                  color: Color(0xFFFFFFFF),
                  fontSize: 13,
                ),
              ),
              const SizedBox(
                width: 16,
              ),
              CustomSwitchWidget(
                onChanged: (value) {
                  setState(() {
                    widget.onChanged!(value);
                  });
                },
              )
            ],
          ),
        )
      ],
    );
  }
}
